<!--跨域功能测试 成功-->
<template>
  <div style="padding: 20px;">
    <h2>跨域测试页面</h2>
    <input type="number" v-model="studentId" placeholder="输入论文ID" />
    <button @click="testApi">下载测试</button>

    <div v-if="loading">请求中...</div>
    <div v-if="error" style="color: red;">错误: {{ error }}</div>
    <div v-if="url" style="margin-top: 10px; color: green;">
      返回 URL: <a :href="url" target="_blank">{{ url }}</a>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import axios from 'axios'
import request from "../../utils/request.js";
import {useTokenStore} from "../../token/token.js";

const studentId = ref('')
const url = ref('')
const error = ref(null)
const loading = ref(false)

const testApi = async () => {
  url.value = ''
  error.value = null
  loading.value = true

  try {
    const res = await request.get('student/getOneScore', {
      params: {studentId: studentId.value}
    })
    console.log(res.data)
    console.log("token测试",useTokenStore().token)
    url.value = res.data.data  // 根据你的 Result 对象
  } catch (err) {
    error.value = err.message
  } finally {
    loading.value = false
  }
}
</script>
